<?php
/**
 * Created by PhpStorm.
 * User: acker
 * Date: 21-06-08
 * Time: 下午6:25
 */

namespace App\Models\yb;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;
use Encore\Admin\Traits\DefaultDatetimeFormat;


class UserWaterTicketRecordModel extends Model
{
    use DefaultDatetimeFormat;

    use SoftDeletes;

    /**
     *
     *计量单位
     * @var string
     */
    protected $table = 'yb_user_water_ticket_record';

    /**
     * 主键
     *
     * @var string
     */
    protected $primaryKey = 'id';


    /**
     * 该模型是否被自动维护时间戳
     *
     * @var bool
     */
    public $timestamps = true;

    /**
     * 追加字段
     *
     * @var string
     */
    protected $appends = ['goods_specs'];

    /**
     * 规格
     * @return mixed
     */
    public function getGoodsSpecsAttribute(){
        $water_ticket_id = $this->water_ticket_id;
        $water_ticket_data = WaterTicketModel::where(['id'=>$water_ticket_id])->first();
        $goods_data = GoodsModel::where(['id'=>$water_ticket_data['goods_id']])->first();
        return $goods_data['goods_title']."&nbsp;&nbsp;&nbsp;&nbsp;".$goods_data['goods_specs'];
    }


}
